package com.shopx.auth.controller;

import com.shopx.auth.bean.SysUserAdd;
import com.shopx.auth.model.SysUserAddModel;
import com.shopx.auth.service.ISysUserAddService;
import com.shopx.base.anno.RepearSubmitChkAnno;
import com.shopx.base.anno.ShopxParamAnno;
import com.shopx.base.controller.BaseController;
import com.shopx.base.dto.Result;
import com.shopx.base.exception.ShopxException;
import com.shopx.base.utils.ResultUtil;
import com.shopx.cmm.DTO.PageDTO;
import com.shopx.core.common.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @author lituo
 * @className: SysUserAddController
 * @date 2022-02-04
 */
@RestController
@Slf4j
@RequestMapping(value = "/sysUserAdd")
public class SysUserAddController extends BaseController {

  @Resource
  private ISysUserAddService sysUserAddService;

  @PostMapping(value = "/queryPageList")
  @ShopxParamAnno
  public Result<PageDTO> queryPageList(@RequestBody SysUserAddModel sysUserAdd) throws ShopxException {
    PageDTO<SysUserAddModel> pageDTO = sysUserAddService.getListPage(sysUserAdd);
    return ResultUtil.ok(pageDTO);
  }

  @PostMapping(value = "/insertOne")
  @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
  @ShopxParamAnno
  public Result<Integer> insertOne(@RequestBody SysUserAdd sysUserAdd) throws ShopxException {
    int result = sysUserAddService.insertSelective(sysUserAdd);
    return ResultUtil.ok(result);
  }

  @PostMapping(value = "/updateOne")
  @RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)
  @ShopxParamAnno
  public Result<Integer> updateOne(@RequestBody SysUserAdd sysUserAdd) throws ShopxException {
    int result = sysUserAddService.updateByPrimaryKeySelective(sysUserAdd);
    return ResultUtil.ok(result);
  }

  @PostMapping(value = "/queryOneByPrimaryKey")
  public Result<SysUserAddModel> queryOneByPrimaryKey(@RequestBody SysUserAdd sysUserAdd) throws ShopxException {
    SysUserAddModel result = sysUserAddService.selectByPrimaryKey(sysUserAdd);
    return ResultUtil.ok(result);
  }

  @PostMapping(value = "/selectOne")
  public Result<SysUserAddModel> selectOne(@RequestBody SysUserAdd sysUserAdd) throws ShopxException {
    SysUserAddModel result = sysUserAddService.selectOne(sysUserAdd);
    return ResultUtil.ok(result);
  }

  @PostMapping(value = "/queryDeposit")
  @ShopxParamAnno
  public Result<PageDTO> queryDeposit(@RequestBody SysUserAddModel sysUserAdd) throws ShopxException {
    PageDTO<SysUserAddModel> pageDTO = sysUserAddService.queryDeposit(sysUserAdd);
    return ResultUtil.ok(pageDTO);
  }

	/*@PostMapping(value = "/deleteChecked")
	@RepearSubmitChkAnno(lockTime = CommonConstant.REQ_TM)   @ShopxParamAnno
public Result<Integer> deleteChecked(@RequestBody SysUserAdd sysUserAdd) throws ShopxException {
		int result = sysUserAddService.deleteByPrimaryKey(sysUserAdd);
		return ResultUtil.ok(result);
	}*/
}

